babl: add performance flag to intent, issue #21
authorØyvind Kolås <pippin@gimp.org>
Tue, 21 Aug 2018 16:08:47 +0000 (18:08 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 21 Aug 2018 16:21:57 +0000 (18:21 +0200)
Add BABL_ICC_INTENT_PERFORMANCE which can be ored into the intente
num when requesting that babl constructs a space using
babl_space_from_icc, when PERFORMANCE is requested babl will permit
matrix+trc over cLUT, and when it is an intent without a performance
modifier this does not apply.

babl/babl-icc.c
babl/babl.h

index 836388585e7f4c77bbdc8c440c077f1f99b1881f..f463e9e190fb2b4444c031eb2ba7b42a7a46a224 100644 (file)
@@ -734,10 +734,10 @@ babl_space_from_icc (const char   *icc_data,
   const Babl *trc_blue  = NULL;
   const char *int_err;
   Babl *ret = NULL;
+  int speed_over_accuracy = intent & BABL_ICC_INTENT_PERFORMANCE;
 
   sign_t profile_class, color_space, pcs;
 
-
   if (!error) error = &int_err;
   *error = NULL;
 
@@ -745,23 +745,17 @@ babl_space_from_icc (const char   *icc_data,
   {
     *error = "icc profile length inconsistency";
   }
-#if 0
-  else if (icc_ver_major > 2)
-  {
-    *error = "only ICC v2 profiles supported";
-  }
-#endif
-  else
-  {
-  profile_class = icc_read (sign, 12);
-  if (strcmp (profile_class.str, "mntr"))
-    *error = "not a monitor-class profile";
   else
   {
-    color_space = icc_read (sign, 16);
-    if (strcmp (color_space.str, "RGB "))
-      *error = "not defining an RGB space";
-  }
+    profile_class = icc_read (sign, 12);
+    if (strcmp (profile_class.str, "mntr"))
+      *error = "not a monitor-class profile";
+     else
+    {
+      color_space = icc_read (sign, 16);
+      if (strcmp (color_space.str, "RGB "))
+        *error = "not defining an RGB space";
+    }
   }
 
   if (!*error)
@@ -771,11 +765,21 @@ babl_space_from_icc (const char   *icc_data,
       *error = "PCS is not XYZ";
   }
 
-  switch (intent)
+  if (!*error)
+  switch (intent & 7) /* enum of intent is in lowest bits */
   {
     case BABL_ICC_INTENT_RELATIVE_COLORIMETRIC:
       /* that is what we do well */
 
+      if (!speed_over_accuracy)
+      {
+        if (icc_tag (state, "A2B0", NULL, NULL) &&
+            icc_tag (state, "B2A0", NULL, NULL))
+        {
+          *error = "use lcms, accuracy desired and cluts are present";
+        }
+      }
+
       break;
     case BABL_ICC_INTENT_PERCEPTUAL:
       /* if there is an A2B0 and B2A0 tags, we do not do what that
index baddd449a50cdecf2c9297cd161d993c30de7f20..2e0735d2f6102610b912aeefcd184d37706b3fb7 100644 (file)
@@ -104,7 +104,9 @@ typedef enum {
   BABL_ICC_INTENT_PERCEPTUAL             = 0,
   BABL_ICC_INTENT_RELATIVE_COLORIMETRIC  = 1,
   BABL_ICC_INTENT_SATURATION             = 2,
-  BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC  = 3
+  BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC  = 3,
+  BABL_ICC_INTENT_PERFORMANCE            = 32
+  // black-point compensation toggle will be added if/when support exist in babl
 } BablIccIntent;
 
 /**
@@ -135,6 +137,7 @@ const Babl *babl_space_from_icc (const char       *icc_data,
                                  BablIccIntent     intent,
                                  const char      **error);
 
+
 // XXX : deprecated
 const Babl *babl_icc_make_space (const char       *icc_data,
                                  int               icc_length,